{include file="layout/layout" /}
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>管理员 - 编辑角色</h3>
                <h5>网站系统角色管理</h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" action="{:url('Agent/submit_role')}" id="roleform" method="post">
        <div class="ncap-form-default">
            <input type="hidden" name="role_type" value="{$mod}">
            <input type="hidden" name="role_id" value="{$info.role_id}">
            <input type="hidden" name="role_agent" value="{$agent_manage}">
            <dl class="row">
                <dt class="tit">
                    <label for="role_name"><em>*</em>角色名称</label>
                </dt>
                <dd class="opt">
                    <div><input type="text" name="role_name" id="role_name" datatype="*" errormsg="角色名称不能为空" value="{$info.role_name}" class="input-txt"></div>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="role_desc"><em>*</em>角色描述</label>
                </dt>
                <dd class="opt">
                    <div><textarea id="role_desc" name="role_desc" datatype="*" errormsg="角色描述不能为空" class="tarea" rows="6">{$info.role_desc}</textarea></div>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="cls_full">权限分配</label>
                </dt>
                <dd style="margin-left:50px;">
                    <div class="ncap-account-container" style="border-top:none;">
                        <h4>
                            <input id="cls_full" onclick="choosebox(this)" type="checkbox">
                            <label>全选</label>
                        </h4>
                    </div>
                    {foreach name="modules" item="menu" key="kk"}
                        <div class="ncap-account-container" style="border-top:none;">
                            <h4>
                                <label>{$rolemenu[$kk]}</label>
                                <input value="1" cka="mod-{$kk}" type="checkbox">
                                <label>全部</label>
                            </h4>
                            <ul class="ncap-account-container-list">
                                {foreach name="menu" item="vv"}
                                    <li>
                                        <label><input class="checkbox" name="right[]" value="{$vv.sm_id}" {if condition="$vv.enable eq 1"}checked{/if} ck="mod-{$kk}" type="checkbox">{$vv.sm_name}</label>
                                    </li>
                                {/foreach}
                            </ul>
                        </div>
                    {/foreach}
                </dd>
            </dl>

            <div class="bot"><button href="JavaScript:void(0);" type="submit" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</button></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('#roleform').Validform({
            tiptype:3,
            beforeSubmit:function(data){
                return true;
            }
        });


        $(":checkbox[cka]").click(function(){
            var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
            if($(this).is(':checked')){
                $cks.each(function(){$(this).prop("checked",true);});
            }else{
                $cks.each(function(){$(this).removeAttr('checked');});
            }
        });
    });

    function choosebox(o){
        var vt = $(o).is(':checked');
        if(vt){
            $('input[type=checkbox]').prop('checked',vt);
        }else{
            $('input[type=checkbox]').removeAttr('checked');
        }
    }


</script>
</body>
</html>